package SysadminFunc;
	import java.io.IOException;  
	import java.util.Date;
	import org.apache.commons.lang.*;
    import javax.servlet.ServletException;  
    import javax.servlet.http.HttpServlet;  
    import javax.servlet.http.HttpServletRequest;  
    import javax.servlet.http.HttpServletResponse;  
    import javax.servlet.http.HttpSession;
    
    import PolladminFunc.*;

    
    public class PolladminMgt extends HttpServlet {  

		private static final long serialVersionUID = -6009372567356533939L;

		public PolladminMgt() {  
           super();   
        }  

        public void destroy() {  
           super.destroy();   
        }  

        public void doGet(HttpServletRequest request, HttpServletResponse response)  
               throws ServletException, IOException {         
        	doPost(request,response);
    }  

        public void doPost(HttpServletRequest request, HttpServletResponse response)  
               throws ServletException, IOException { 
        	HttpSession session=request.getSession(true);
        	String username=request.getParameter("username");
        	String email=request.getParameter("email");
        	String fname=request.getParameter("fname");
        	String lname=request.getParameter("lname");

        	Polladmin pa=new Polladmin();
        	pa.setUsername(username);
        	pa.setPassword(RandomStringUtils.random(6, true, true));	
        	pa.setEmail(email);
        	pa.setAccessibility(4); 	
        	pa.setFname(fname);
        	pa.setLname(lname);
			
        	PolladminDAO pad = new PolladminDAO();
        	pad.add(pa);
        	response.sendRedirect("polladminmgt.jsp");
        }
 
        public void init() throws ServletException {  
           // Put your code here  
        }  
    }  